{include file="public/head"/}
<style>
    .main-content {
        margin-left: 0px;
        min-height: 80%;
    }

    .row .cf {
        margin-bottom: 10px;
    }
</style>


<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <div class="main-container-inner">
        <a class="menu-toggler" id="menu-toggler" href="#">
            <span class="menu-text"></span>
        </a>
        {include file="public/nav"/}

        <div class="main-content">
            <div class="page-content">
                <div class="row">
                    <div class="well">
                        <h1 class=" lighter smaller">
              <span class="blue bigger-125">
                <i class="ace-icon fa fa-phone-square"></i>
              </span>
                            客户提醒
                            <a style="font-size:13px;" href="{:url('main/modulefront')}">返回首页</a>
                        </h1>
                        <hr>
                        <div class="space"></div>

                        <div class="row-fluid">
                            <!--<h3 class="lighter block green">选择或添加客户信息</h3>-->
                            <!--<a class="btn btn-info" href="#modal-fmClients" data-toggle="modal">
                              <i class="icon-ok bigger-110"></i>
                              添加客户
                            </a>-->
                            <!--数据筛选表单-->
                            <!--<form class="form-inline fmClientQuery-hook">
                              <input class="input-small" name="name" placeholder="客户姓名"/>
                              <input class="input-large" name="address" placeholder="地址"/>
                              <input class="input-small" name="phone" placeholder="电话"/>
                              <button type="button" class="btn btn-info btn-sm" onclick="addWork.search();">
                                <i class="fa fa-search bigger-110"></i>
                                查找
                              </button>
                              <button type="button" class="btn btn-primary btn-sm" onclick="addWork.searchNull();">
                                <i class="fa fa-remove bigger-110"></i>
                                清空
                              </button>
                            </form>-->
                            <!--客户数据表-->
                            <table id="tbClients"></table>
                            <!--客户表页码内容-->
                            <div id="tbClientsPager"></div>

                            <!--添加客户模态框-->
                            <div id="modal-fmClients" class="modal" tabindex="-1">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                            <h4 class="blue bigger">添加客户信息</h4>
                                        </div>
                                        <div class="modal-body overflow-visible">
                                            <!--添加客户表单-->
                                            <form class="form-horizontal" id="fmClient" method="post">
                                                <input type="hidden" name="id" value="">
                                                <div class="form-group">
                                                    <label class="col-sm-3 control-label no-padding-right"> 姓名 </label>
                                                    <div class="col-sm-9">
                                                        <input name="name" placeholder="姓名" class="col-xs-10 col-sm-5"
                                                               value="">
                                                        <span class="help-inline col-xs-12 col-sm-7">
                                          <span class="middle"></span>
                                        </span>
                                                    </div>
                                                </div>
                                                <div class="space-4"></div>
                                                <div class="form-group">
                                                    <label class="col-sm-3 control-label no-padding-right"> 地址 </label>
                                                    <div class="col-sm-9">
                                                        <input name="address" placeholder="地址"
                                                               class="col-xs-10 col-sm-5" value="">
                                                        <span class="help-inline col-xs-12 col-sm-7">
                                          <span class="middle"></span>
                                        </span>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-3 control-label no-padding-right"> 电话 </label>
                                                    <div class="col-sm-9">
                                                        <input name="phone" placeholder="电话" class="col-xs-10 col-sm-5"
                                                               value="">
                                                        <span class="middle"></span>
                                                        </span>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>

                                        <div class="modal-footer">
                                            <button class="btn btn-sm" data-dismiss="modal">
                                                <i class="icon-remove"></i>
                                                取消
                                            </button>
                                            <button class="btn btn-sm btn-primary">
                                                <i class="icon-ok"></i>
                                                保存
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <hr>
                        <div class="space"></div>
                    </div>
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div><!-- /.main-content -->

    </div><!-- /.main-container-inner -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
</div>
<!-- /.main-container -->
{include file="public/footerjs"/}

<script>
    $(function () {
        //加载数据
        var $tbClients = $('#tbClients'), $pager = $('#tbClientsPager');
        $tbClients.jqGrid({
            url: "{:url('work/getWorkNotifyClient')}",
            datatype: 'json',
            mttype: 'post',
            colNames: ['车牌', '上次保养日期', '上次保养里程', '客户', '电话', '操作'],
            colModel: [
                {name: 'car_num', index: 'car_num', width: '100', align: 'center'},
                {name: 'date', index: 'date', width: '100', align: 'center'},
                {name: 'mileage', index: 'mileage', width: '100', align: 'center'},
                {name: 'name', index: 'name', width: '100', align: 'center'},
                {name: 'phone', index: 'phone', width: '100', align: 'center'},
                {
                    name: 'id', index: 'id', width: '100', align: 'center',
                    formatter: function (value, options, obj) {
                        var res = '<a href="/admin/invoice/index/id/' + value + '" target="_blank" style="cursor:pointer;">明细</a>';
                        res += '&nbsp;&nbsp;<a id="btnSee' + value + '" onclick="notified(' + value + ')" style="cursor:pointer;">已提醒</a>';
                        return res;
                    }
                },
            ],
            height: 'auto',
//      pager: '#tbClientsPager',
            viewrecords: true,
            rowNum: 'all',
//      rowList: [10, 20, 40],
            autowidth: true
        });
        // 隐藏水平方向滚动条
        $tbClients.closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
    });
    notified = function (work_id) {
        $.post("{:url('work/doNotify')}", {param: JSON.stringify({id: work_id, enable: 1})}, function () {
            $('#tbClients').jqGrid('setGridParam', {}).trigger("reloadGrid");
        })
    };
    addWork = {
        search: function () {
            var $fmQuery = $('.fmClientQuery-hook');
            var param = ittaoli.serializeObject($fmQuery);
            $('#tbClients').jqGrid('setGridParam', {
                postData: {q: JSON.stringify(param)},
                page: 1
            }).trigger("reloadGrid");
        },
        searchNull: function () {
            $('.fmClientQuery-hook input').val('');
            var param = {};
            $('#tbClients').jqGrid('setGridParam', {
                postData: {q: JSON.stringify(param)},
                page: 1
            }).trigger("reloadGrid");
        }
    };
</script>

{include file="public/foot"/}
